#ifndef WIDGET_H
#define WIDGET_H

#include "pack.h"
#include "myClient.h"
#include "dbhelper.h"

#include <QWidget>
#include <QTcpServer>
#include <QBuffer>
#include <QImageReader>
#include <QPainter>
#include <imgproc.hpp>
#include <opencv.hpp>
#include <face.hpp>
#include <core.hpp>
#include <highgui.hpp>
#include <QDateTime>

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    QPixmap facePredict(QImage& face,myClient* client);
    void sendFace(QPixmap& pic,myClient* client);

private slots:

private:
    Ui::Widget *ui;
    QTcpServer* server;
    QHostAddress addr;
    int port;

    QVector<myClient*> users;
    QByteArray camera_image;

    cv::CascadeClassifier *classifier;
    std::vector<cv::Rect> faces;//用来存放检测结果的容器
    QPainter painter;
    QPen pen;
    cv::Ptr<cv::face::LBPHFaceRecognizer> recognizer;
    std::vector<cv::Mat> setFace;
    std::vector<int> faceFlag;
    int faceCount = 0;
    DbHelper* db;

    int flag = 0;

    QString username; //从服务器接收人脸识别的人的姓名

public slots:
    void onNewConnection();// 处理客户端连接时候发出的信号
    void onDisConnected();
    void onReadyRead();

};
#endif // WIDGET_H
